package com.huashi.dealer.modular.business.goods.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huashi.dealer.commonEntity.*;
import com.huashi.dealer.core.exception.CommonException;
import com.huashi.dealer.core.util.BizAssertUtil;
import com.huashi.dealer.core.util.SaTokenUtil;
import com.huashi.dealer.modular.business.category.mapper.CategoryMapper;
import com.huashi.dealer.modular.business.goods.bo.GoodsListBo;
import com.huashi.dealer.modular.business.goods.mapper.CartMapper;
import com.huashi.dealer.modular.business.goods.mapper.CommentMapper;
import com.huashi.dealer.modular.business.goods.mapper.GoodsImageMapper;
import com.huashi.dealer.modular.business.goods.mapper.GoodsSkuMapper;
import com.huashi.dealer.modular.business.goods.param.GoodsDetail;
import com.huashi.dealer.modular.business.goods.param.GoodsDetailVo;
import com.huashi.dealer.modular.business.goods.service.GoodsService;
import com.huashi.dealer.modular.business.goods.param.GoodsResponseParam;
import com.huashi.dealer.modular.business.goods.vo.GoodsListVo;
import com.huashi.dealer.modular.business.upload.mapper.UploadFileMapper;
import com.huashi.dealer.modular.business.goods.mapper.GoodsMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * API商品Service实现类
 *
 * @author 谭陈强
 * @since 2025-07-30
 */
@Slf4j
@Service("apiGoodsServiceImpl")
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Resource
    private GoodsMapper goodsMapper;

    @Resource
    private GoodsSkuMapper goodsSkuMapper;

    @Resource
    private GoodsImageMapper goodsImageMapper;

    @Resource
    private CategoryMapper categoryMapper;

    @Resource
    private CommentMapper commentMapper;

    @Resource
    private CartMapper cartMapper;

    @Resource
    private UploadFileMapper uploadFileMapper;

    @Override
    public GoodsResponseParam getCategoryList() {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            // TODO: 获取商品分类列表
            // 这里需要注入CategoryMapper并查询数据库
            
            // 模拟商品分类列表
            List<GoodsResponseParam.CategoryInfo> categoryList = new ArrayList<>();
            GoodsResponseParam.CategoryInfo category = new GoodsResponseParam.CategoryInfo();
            category.setCategoryId(1L);
            category.setCategoryName("护肤品类");
            category.setCategoryImage("https://example.com/category.jpg");
            category.setCategorySort(1);
            category.setIsGoodsType(1);
            category.setCategoryStatus(10);
            category.setCreateTime(LocalDateTime.now());
            categoryList.add(category);
            
            responseParam.setCategoryList(categoryList);
            
        } catch (Exception e) {
            throw new CommonException("获取商品分类失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public Page<GoodsListVo> getGoodsList(GoodsListBo bo,Page<Goods> page) {
        try {
            // 构建查询条件
            LambdaQueryWrapper<Goods> wrapper = new LambdaQueryWrapper<>();
            if(ObjectUtil.isNotNull(bo.getCategoryId())) {
                Category category = categoryMapper.selectById(bo.getCategoryId());
                if(category != null && category.getParentId() !=0 ){
                    wrapper.eq(Goods::getCategoryId, category.getCategoryId());
                }
                if(category != null && category.getParentId() ==0){
                    LambdaQueryWrapper<Category> categoryWrapper = new LambdaQueryWrapper<>();
                    categoryWrapper.eq(Category::getParentId, category.getCategoryId());
                    List<Category> categories = categoryMapper.selectList(categoryWrapper);
                    wrapper.in(CollUtil.isNotEmpty(categories), Goods::getCategoryId, categories.stream().map(Category::getCategoryId).toArray());
                }
            }
            wrapper.eq(ObjectUtil.isNotNull(bo.getStatus()), Goods::getGoodsStatus, bo.getStatus())
//                    .eq(ObjectUtil.isNotNull(bo.getCategoryId()), Goods::getCategoryId, bo.getCategoryId())
                    .eq(bo.isNewProduct(), Goods::getIsNewproduct, bo.isNewProduct())
                    .eq(bo.isHotSelling(), Goods::getIsHotsellingitem, bo.isHotSelling())
                    .eq(bo.getIsType() != null, Goods::getIsType, bo.getIsType());
            // 搜索筛选
            if (StringUtils.hasText(bo.getSearch())) {
                wrapper.and(w -> w.like(Goods::getGoodsName, bo.getSearch())
                        .or().like(Goods::getBarCode, bo.getSearch()));
            }
            // 经销商商品过滤
            if (bo.getUserId() != null) {
                Long[] userGoodsIds = bo.getUserGoodsIdArray();
                if (userGoodsIds.length > 0) {
                    wrapper.notIn(Goods::getGoodsId, Arrays.asList(userGoodsIds));
                }
            }
            
            // 排序
            if ("sales".equals(bo.getSortType())) {
                wrapper.orderByDesc(Goods::getSalesActual);
            } else if ("price".equals(bo.getSortType())) {
                if (Boolean.TRUE.equals(bo.getSortPrice())) {
                    wrapper.orderByDesc(Goods::getGoodsPrice);
                } else {
                    wrapper.orderByAsc(Goods::getGoodsPrice);
                }
            } else {
                // 默认排序
                wrapper.orderByAsc(Goods::getGoodsSort)
                       .orderByDesc(Goods::getGoodsId);
            }
            // 分页查询
            wrapper.eq(Goods::getIsDelete,0);
            wrapper.eq(Goods::getGoodsStatus,10);
            Page<Goods> goodsPage = goodsMapper.selectPage(page, wrapper);
            
            // 转换为GoodsListVo
            Page<GoodsListVo> resultPage = new Page<>();
            resultPage.setCurrent(goodsPage.getCurrent());
            resultPage.setSize(goodsPage.getSize());
            resultPage.setTotal(goodsPage.getTotal());
            resultPage.setPages(goodsPage.getPages());
            
            List<GoodsListVo> goodsListVoList = new ArrayList<>();
            for (Goods goods : goodsPage.getRecords()) {
                GoodsListVo goodsListVo = new GoodsListVo();
                // 复制Goods属性到GoodsListVo
                BeanUtil.copyProperties(goods, goodsListVo);
                goodsListVo.setCategory(categoryMapper.selectById(goods.getCategoryId()));
                List<String> imageUrl =goodsImageMapper.getFileUrlByGoodsId(goods.getGoodsId());
                if(!imageUrl.isEmpty()) {
//                    if(imageUrl.size() > 1) {
//                        goodsListVo.setGoodsImage(CollUtil.join(imageUrl, ","));
//                    } else {
                        goodsListVo.setGoodsImage(imageUrl.get(0));
//                    }
                }
                // 查询商品SKU信息
                LambdaQueryWrapper<GoodsSku> skuWrapper = new LambdaQueryWrapper<>();
                skuWrapper.eq(GoodsSku::getGoodsId, goods.getGoodsId());
                skuWrapper.orderByAsc(GoodsSku::getGoodsSkuId);
                skuWrapper.last("LIMIT 1"); // 只取第一个SKU
                GoodsSku sku = goodsSkuMapper.selectOne(skuWrapper);
                goodsListVo.setSkus(sku);
                goodsListVoList.add(goodsListVo);
            }
            
            resultPage.setRecords(goodsListVoList);
            return resultPage;
            
        } catch (Exception e) {
            throw new CommonException("获取商品列表失败：" + e.getMessage());
        }
    }

    @Override
    public GoodsResponseParam getGoodsList(Long categoryId, String search, Integer isNewProduct, Integer isHotSellingItem, Integer page, Integer listRows) {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            // TODO: 获取商品列表
            // 这里需要注入GoodsMapper并查询数据库
            
            // 模拟商品列表
            List<GoodsResponseParam.GoodsInfo> goodsList = new ArrayList<>();
            GoodsResponseParam.GoodsInfo goods = new GoodsResponseParam.GoodsInfo();
            goods.setGoodsId(1L);
            goods.setGoodsName("测试商品");
            goods.setSellingPoint("商品卖点");
            goods.setCategoryId(1L);
            goods.setBarCode("123456789");
            goods.setSpecType(10);
            goods.setDeductStockType(10);
            goods.setGoodsSort(1);
            goods.setDeliveryId(1L);
            goods.setIsPointsGift(1);
            goods.setIsPointsDiscount(1);
            goods.setIsEnableGrade(1);
            goods.setIsAloneGrade(0);
            goods.setAloneGradeEquity("");
            goods.setIsIndDealer(0);
            goods.setDealerMoneyType(10);
            goods.setFirstMoney(new BigDecimal("100.00"));
            goods.setSecondMoney(new BigDecimal("90.00"));
            goods.setThirdMoney(new BigDecimal("80.00"));
            
            // 设置商品状态
            GoodsResponseParam.GoodsStatus goodsStatus = new GoodsResponseParam.GoodsStatus();
            goodsStatus.setText("上架");
            goodsStatus.setValue(10);
            goods.setGoodsStatus(goodsStatus);
            
            goods.setIsType(10);
            goods.setGoodsImage("https://example.com/goods.jpg");
            goods.setContent("商品详情内容");
            goods.setCreateTime(LocalDateTime.now());
            goodsList.add(goods);
            
            responseParam.setGoodsList(goodsList);
            responseParam.setTotal(1L);
            responseParam.setCurrentPage(page != null ? page : 1);
            responseParam.setPerPage(listRows != null ? listRows : 10);
            responseParam.setLastPage(1);
            
        } catch (Exception e) {
            throw new CommonException("获取商品列表失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public GoodsDetailVo getGoodsDetail(Long goodsId, User user) {
        GoodsDetailVo goodsDetailVo = new GoodsDetailVo();
        try {
            BizAssertUtil.notNull(goodsId, 1001, "商品ID不能为空");
            // 1. 查询商品主表信息
            Goods goods = goodsMapper.selectById(goodsId);
            BizAssertUtil.notNull(goods, 1002, "商品不存在");

            // 2. 检查经销商用户是否有权限查看此商品
            if (user != null && user.getGoodsIds() != null && !user.getGoodsIds().trim().isEmpty()) {
                String[] userGoodsIds = user.getGoodsIds().split(",");
                boolean hasPermission = false;
                for (String id : userGoodsIds) {
                    if (id.trim().equals(goodsId.toString())) {
                        hasPermission = true;
                        break;
                    }
                }
                if (!hasPermission) {
                    throw new CommonException("您没有权限查看此商品");
                }
            }

            // 3. 组装GoodsDetail对象
            GoodsDetail detail = new GoodsDetail();
            
            // 复制商品基本信息
            detail.setGoodsId(goods.getGoodsId());
            detail.setGoodsName(goods.getGoodsName());
            detail.setCategoryId(goods.getCategoryId());
            detail.setGoodsImage(goods.getGoodsImage());
            detail.setGoodsStatus(goods.getGoodsStatus());
            detail.setIsType(goods.getIsType());
            detail.setIsNewproduct(goods.getIsNewproduct());
            detail.setIsHotsellingitem(goods.getIsHotsellingitem());
            detail.setGoodsSort(goods.getGoodsSort());
            detail.setGoodsPrice(goods.getGoodsPrice());
            detail.setGoodsStock(goods.getGoodsStock());
            detail.setContent(goods.getContent());
            detail.setBarCode(goods.getBarCode());
            detail.setCreateTime(goods.getCreateTime());
            detail.setUpdateTime(goods.getUpdateTime());
            
            // 3. 设置商品状态
            GoodsDetail.GoodStatusVo goodStatus = new GoodsDetail.GoodStatusVo();
            if (goods.getGoodsStatus() != null) {
                switch (goods.getGoodsStatus()) {
                    case 10:
                        goodStatus.setText("上架");
                        goodStatus.setValue("10");
                        break;
                    case 20:
                        goodStatus.setText("下架");
                        goodStatus.setValue("20");
                        break;
                    default:
                        goodStatus.setText("未知");
                        goodStatus.setValue(String.valueOf(goods.getGoodsStatus()));
                }
            }
            detail.setGoodStatus(goodStatus);
            
            // 4. 查询商品图片列表
            List<GoodsImage> goodsImages = goodsImageMapper.selectByGoodsId(goodsId);
            List<UploadFile> images = new ArrayList<>();
            for (GoodsImage goodsImage : goodsImages) {
                UploadFile uploadFile = uploadFileMapper.selectById(goodsImage.getImageId());
                if (uploadFile != null) {
                    images.add(uploadFile);
                }
            }
            detail.setImages(images);
            
            // 5. 查询商品SKU列表
            List<GoodsSku> skuList = goodsSkuMapper.selectByGoodsId(goodsId);
            detail.setSku(skuList);
            
            // 6. 设置商品销量（sales_initial + sales_actual）
            int goodsSales = (goods.getSalesInitial() != null ? goods.getSalesInitial() : 0) + 
                           (goods.getSalesActual() != null ? goods.getSalesActual() : 0);
            detail.setGoodsSaless(goodsSales);
            detail.setGoodsSales(goodsSales);
            // 7. 查询商品分类信息
            if (goods.getCategoryId() != null) {
                Category category = categoryMapper.selectById(goods.getCategoryId());
                detail.setCategory(category);
            }
            
            // 8. 查询商品评论数据（取2条，带用户信息）
            List<Comment> commentData = commentMapper.selectByGoodsIdWithUser(goodsId, 2);
            detail.setCommentData(commentData);
            
            // 9. 计算是否参与会员等级折扣
            boolean isUserGrade = goods.getIsEnableGrade() != null && goods.getIsEnableGrade() == 1;
            detail.setBooleanUserGrade(isUserGrade);

            // 10. 查询购物车数量（如果有token，解析用户ID）
            int cartTotalNum = 0;

            // 根据token解析用户ID
            Long userId = SaTokenUtil.getLoginId();
            if (userId != null) {
                cartTotalNum = cartMapper.getTotalNum(userId, 10); // 10表示普通商品
            }

            // 11. 设置商品规格（取第一个SKU作为默认规格）
            if (!skuList.isEmpty()) {
                detail.setGoodsSku(skuList.get(0));
            }
            
            // 设置返回结果
            goodsDetailVo.setGoodsDetail(detail);
            goodsDetailVo.setCartTotalNum(cartTotalNum);
            
        } catch (Exception e) {
            throw new CommonException("获取商品详情失败：" + e.getMessage());
        }
        
        return goodsDetailVo;
    }

    /**
     * 根据token解析用户ID（临时方法，实际应该从JWT或Session中获取）
     */

    @Override
    public List<GoodsDetailVo> getBarCodeDetail(String barCode) {
        List<GoodsDetailVo> responseParam = new ArrayList<>();
        
        try {
            BizAssertUtil.notNull(barCode, 1001, "条形码不能为空");

            // 这里需要注入GoodsMapper并查询数据库
            LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
            queryWrapper.eq(Goods::getBarCode, barCode)
                    .eq(Goods::getIsDelete, 0)
                    .eq(Goods::getGoodsStatus, 10);
            List<Goods> goods = this.goodsMapper.selectList(queryWrapper);
            if(goods.isEmpty()){
                return responseParam;
            }

            // 与PHP保持一致：返回 detail + cart_total_num
            for (Goods good : goods) {
                GoodsDetailVo detailVo = this.getGoodsDetail(good.getGoodsId(), null);
                responseParam.add(detailVo);
            }
//
//            // 兼容根据商品类型统计购物车数量
//            int cartTotalNum = 0;
//            Long userId = null;
//            try { userId = SaTokenUtil.getLoginId(); } catch (Exception ignore) {}
//            if (userId != null) {
//                Integer isGoodsType = goods.getIsType();
//                if (isGoodsType == null) { isGoodsType = 10; }
//                cartTotalNum = cartMapper.getTotalNum(userId, isGoodsType);
//            }
//            detailVo.setCartTotalNum(cartTotalNum);
//
//            responseParam = detailVo;
        } catch (Exception e) {
            throw new CommonException("获取扫码商品详情失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public GoodsResponseParam generateGoodsPoster(Long goodsId, String token) {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            if (goodsId == null) {
                throw new CommonException("商品ID不能为空");
            }
            
            // TODO: 生成商品海报
            // 这里需要调用海报生成服务
            
            // 模拟商品海报
            responseParam.setPoster("https://example.com/poster.jpg");
            
        } catch (Exception e) {
            throw new CommonException("生成商品海报失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public GoodsResponseParam searchGoods(String keyword, Long categoryId, Integer page, Integer listRows) {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            if (keyword == null || keyword.isEmpty()) {
                throw new CommonException("搜索关键词不能为空");
            }
            
            // TODO: 商品搜索
            // 这里需要注入GoodsMapper并查询数据库
            
            // 模拟搜索结果
            List<GoodsResponseParam.GoodsInfo> goodsList = new ArrayList<>();
            GoodsResponseParam.GoodsInfo goods = new GoodsResponseParam.GoodsInfo();
            goods.setGoodsId(1L);
            goods.setGoodsName("搜索商品：" + keyword);
            goods.setSellingPoint("搜索商品卖点");
            goods.setCategoryId(categoryId != null ? categoryId : 1L);
            goods.setBarCode("123456789");
            goods.setSpecType(10);
            goods.setDeductStockType(10);
            goods.setGoodsSort(1);
            goods.setDeliveryId(1L);
            goods.setIsPointsGift(1);
            goods.setIsPointsDiscount(1);
            goods.setIsEnableGrade(1);
            goods.setIsAloneGrade(0);
            goods.setAloneGradeEquity("");
            goods.setIsIndDealer(0);
            goods.setDealerMoneyType(10);
            goods.setFirstMoney(new BigDecimal("100.00"));
            goods.setSecondMoney(new BigDecimal("90.00"));
            goods.setThirdMoney(new BigDecimal("80.00"));
            
            // 设置商品状态
            GoodsResponseParam.GoodsStatus goodsStatus = new GoodsResponseParam.GoodsStatus();
            goodsStatus.setText("上架");
            goodsStatus.setValue(10);
            goods.setGoodsStatus(goodsStatus);
            
            goods.setIsType(10);
            goods.setGoodsImage("https://example.com/goods.jpg");
            goods.setContent("搜索商品详情内容");
            goods.setCreateTime(LocalDateTime.now());
            goodsList.add(goods);
            
            responseParam.setGoodsList(goodsList);
            responseParam.setTotal(1L);
            responseParam.setCurrentPage(page != null ? page : 1);
            responseParam.setPerPage(listRows != null ? listRows : 10);
            responseParam.setLastPage(1);
            
        } catch (Exception e) {
            throw new CommonException("商品搜索失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public GoodsResponseParam getHotGoods(Integer limit) {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            // TODO: 获取热门商品
            // 这里需要注入GoodsMapper并查询数据库
            
            // 模拟热门商品
            List<GoodsResponseParam.GoodsInfo> goodsList = new ArrayList<>();
            GoodsResponseParam.GoodsInfo goods = new GoodsResponseParam.GoodsInfo();
            goods.setGoodsId(1L);
            goods.setGoodsName("热门商品");
            goods.setSellingPoint("热门商品卖点");
            goods.setCategoryId(1L);
            goods.setBarCode("123456789");
            goods.setSpecType(10);
            goods.setDeductStockType(10);
            goods.setGoodsSort(1);
            goods.setDeliveryId(1L);
            goods.setIsPointsGift(1);
            goods.setIsPointsDiscount(1);
            goods.setIsEnableGrade(1);
            goods.setIsAloneGrade(0);
            goods.setAloneGradeEquity("");
            goods.setIsIndDealer(0);
            goods.setDealerMoneyType(10);
            goods.setFirstMoney(new BigDecimal("100.00"));
            goods.setSecondMoney(new BigDecimal("90.00"));
            goods.setThirdMoney(new BigDecimal("80.00"));
            
            // 设置商品状态
            GoodsResponseParam.GoodsStatus goodsStatus = new GoodsResponseParam.GoodsStatus();
            goodsStatus.setText("上架");
            goodsStatus.setValue(10);
            goods.setGoodsStatus(goodsStatus);
            
            goods.setIsType(10);
            goods.setGoodsImage("https://example.com/goods.jpg");
            goods.setContent("热门商品详情内容");
            goods.setCreateTime(LocalDateTime.now());
            goodsList.add(goods);
            
            responseParam.setGoodsList(goodsList);
            
        } catch (Exception e) {
            throw new CommonException("获取热门商品失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public GoodsResponseParam getNewGoods(Integer limit) {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            // TODO: 获取新品推荐
            // 这里需要注入GoodsMapper并查询数据库
            
            // 模拟新品推荐
            List<GoodsResponseParam.GoodsInfo> goodsList = new ArrayList<>();
            GoodsResponseParam.GoodsInfo goods = new GoodsResponseParam.GoodsInfo();
            goods.setGoodsId(1L);
            goods.setGoodsName("新品推荐");
            goods.setSellingPoint("新品推荐卖点");
            goods.setCategoryId(1L);
            goods.setBarCode("123456789");
            goods.setSpecType(10);
            goods.setDeductStockType(10);
            goods.setGoodsSort(1);
            goods.setDeliveryId(1L);
            goods.setIsPointsGift(1);
            goods.setIsPointsDiscount(1);
            goods.setIsEnableGrade(1);
            goods.setIsAloneGrade(0);
            goods.setAloneGradeEquity("");
            goods.setIsIndDealer(0);
            goods.setDealerMoneyType(10);
            goods.setFirstMoney(new BigDecimal("100.00"));
            goods.setSecondMoney(new BigDecimal("90.00"));
            goods.setThirdMoney(new BigDecimal("80.00"));
            
            // 设置商品状态
            GoodsResponseParam.GoodsStatus goodsStatus = new GoodsResponseParam.GoodsStatus();
            goodsStatus.setText("上架");
            goodsStatus.setValue(10);
            goods.setGoodsStatus(goodsStatus);
            
            goods.setIsType(10);
            goods.setGoodsImage("https://example.com/goods.jpg");
            goods.setContent("新品推荐详情内容");
            goods.setCreateTime(LocalDateTime.now());
            goodsList.add(goods);
            
            responseParam.setGoodsList(goodsList);
            
        } catch (Exception e) {
            throw new CommonException("获取新品推荐失败：" + e.getMessage());
        }
        
        return responseParam;
    }

    @Override
    public GoodsResponseParam getRecommendGoods(Long goodsId, Integer limit) {
        GoodsResponseParam responseParam = new GoodsResponseParam();
        
        try {
            // TODO: 获取商品推荐
            // 这里需要注入GoodsMapper并查询数据库
            
            // 模拟商品推荐
            List<GoodsResponseParam.GoodsInfo> goodsList = new ArrayList<>();
            GoodsResponseParam.GoodsInfo goods = new GoodsResponseParam.GoodsInfo();
            goods.setGoodsId(1L);
            goods.setGoodsName("推荐商品");
            goods.setSellingPoint("推荐商品卖点");
            goods.setCategoryId(1L);
            goods.setBarCode("123456789");
            goods.setSpecType(10);
            goods.setDeductStockType(10);
            goods.setGoodsSort(1);
            goods.setDeliveryId(1L);
            goods.setIsPointsGift(1);
            goods.setIsPointsDiscount(1);
            goods.setIsEnableGrade(1);
            goods.setIsAloneGrade(0);
            goods.setAloneGradeEquity("");
            goods.setIsIndDealer(0);
            goods.setDealerMoneyType(10);
            goods.setFirstMoney(new BigDecimal("100.00"));
            goods.setSecondMoney(new BigDecimal("90.00"));
            goods.setThirdMoney(new BigDecimal("80.00"));
            
            // 设置商品状态
            GoodsResponseParam.GoodsStatus goodsStatus = new GoodsResponseParam.GoodsStatus();
            goodsStatus.setText("上架");
            goodsStatus.setValue(10);
            goods.setGoodsStatus(goodsStatus);
            
            goods.setIsType(10);
            goods.setGoodsImage("https://example.com/goods.jpg");
            goods.setContent("推荐商品详情内容");
            goods.setCreateTime(LocalDateTime.now());
            goodsList.add(goods);
            
            responseParam.setGoodsList(goodsList);
            
        } catch (Exception e) {
            throw new CommonException("获取商品推荐失败：" + e.getMessage());
        }
        
        return responseParam;
    }
} 